home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / daemons / ipServer / RCS / tcpTimer.h,v < prev    next >
Encoding:
Text File  |  1989-08-16  |  8.6 KB  |  324 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     89.08.15.19.55.52;  author rab;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     88.09.28.11.49.48;  author mendel;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.08.16.11.22.20;  author mendel;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.04.27.09.15.38;  author brent;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.04.27.09.02.08;  author brent;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @TCP Timer defs
  37. @
  38.  
  39.  
  40. 1.5
  41. log
  42. @Commented #endif labels.
  43. @
  44. text
  45. @/*
  46.  * tcpTimer.h --
  47.  *
  48.  *    Definitions of timers for the TCP protocol.
  49.  *
  50.  *    Based on 4.3BSD @@(#)tcp_timer.h    7.5 (Berkeley) 3/16/88
  51.  *
  52.  * Copyright 1987 Regents of the University of California
  53.  * All rights reserved.
  54.  * Permission to use, copy, modify, and distribute this
  55.  * software and its documentation for any purpose and without
  56.  * fee is hereby granted, provided that the above copyright
  57.  * notice appear in all copies.  The University of California
  58.  * makes no representations about the suitability of this
  59.  * software for any purpose.  It is provided "as is" without
  60.  * express or implied warranty.
  61.  *
  62.  * $Header: /sprite/src/daemons/ipServer/RCS/tcpTimer.h,v 1.4 88/09/28 11:49:48 mendel Exp Locker: rab $ SPRITE (Berkeley)
  63.  */
  64.  
  65. #ifndef _IPS_TCP_TIMER
  66. #define _IPS_TCP_TIMER
  67. /*
  68.  * Definitions of the 4 TCP timers:
  69.  *
  70.  * The TCP_TIMER_REXMT timer is used to force retransmissions.  The TCB
  71.  * has the TCP_TIMER_REXMT timer set whenever segments have been sent for
  72.  * which ACKs are expected but not yet received.  If an ACK is received
  73.  * that advances tcbPtr->send.unAck, then the retransmit timer is cleared (if
  74.  * there are no more outstanding segments) or reset to the base value (if
  75.  * more ACKs are expected).  Whenever the retransmit timer goes off,
  76.  * we retransmit one unacknowledged segment, and do a backoff on the
  77.  * retransmit timer.
  78.  *
  79.  * The TCP_TIMER_PERSIST timer is used to keep window size information
  80.  * flowing even if the window goes shut.  If all previous transmissions
  81.  * have been acknowledged (so that there are no retransmissions in
  82.  * progress), and the window is too small to bother sending anything, then
  83.  * we start the TCP_TIMER_PERSIST timer.  When it expires, if the window
  84.  * is nonzero, we go into the transmit state.  Otherwise, at intervals, send a
  85.  * single byte into the peer's window to force him to update our window
  86.  * information.  We do this at most as TCP_MIN_PERSIST_TIME time
  87.  * intervals, but no more frequently than the current estimate of
  88.  * round-trip packet time.  The TCP_TIMER_PERSIST timer is cleared
  89.  * whenever we receive a window update from the peer.
  90.  *
  91.  * The TCP_TIMER_KEEP_ALIVE timer is used to keep connections alive.  If a
  92.  * connection is idle (no segments received) for TCP_KEEP_TIME_INIT amount
  93.  * of time, but not yet established, then we drop the connection.  Once
  94.  * the connection is established, if the connection is idle for
  95.  * TCP_KEEP_TIMER_IDLE time (and keepalives have been enabled on the
  96.  * socket), we begin to probe the connection.  We force the peer to send
  97.  * us a segment by sending:
  98.  *      <SEQ=SEND.UNACK-1><ACK=RECV.NEXT><CTL=ACK>
  99.  * This segment is (deliberately) outside the window, and should elicit an
  100.  * ack segment in response from the peer.  If, despite the
  101.  * TCP_TIMER_KEEP_ALIVE initiated segments we cannot elicit a response
  102.  * from a peer after TCP_KEEP_COUNT times, then we drop the connection.
  103.  */
  104.  
  105. #define    TCP_NUM_TIMERS        4
  106.  
  107. #define    TCP_TIMER_REXMT        0        /* retransmit */
  108. #define    TCP_TIMER_PERSIST    1        /* retransmit persistence */
  109. #define    TCP_TIMER_KEEP_ALIVE    2        /* keep alive */
  110. #define    TCP_TIMER_2MSL        3        /* 2*msl quiet time timer */
  111.  
  112. #ifdef    TCP_TIMER_NAMES
  113. char *tcpTimers[] =
  114.     { "REXMT", "PERSIST", "KEEP ALIVE", "2MSL" };
  115. #endif
  116.  
  117. /*
  118.  * Number of times per second to update timers.
  119.  */
  120.  
  121. #define    TIMER_UPDATE_RATE    2
  122. /*
  123.  * Time constants: (In timer ticks)
  124.  *
  125.  * TCP_MSL_TIME        - maximum segment lifetime.
  126.  * TCP_SRTT_BASE_TIME    - base roundtrip time; if 0, no idea yet.
  127.  * TCP_SRTT_DEFLT_TIME    - assumed RTT if no info.
  128.  * TCP_KEEP_TIME_INIT    - initial connect keep-alive time.
  129.  * TCP_KEEP_TIME_IDLE    - default time before probing.
  130.  * TCP_KEEP_TIME_INTVL    - default proble interval.
  131.  * TCP_MIN_PERSIST_TIME    - retransmit persistence.
  132.  * TCP_MAX_PERSIST_TIME    - maximum retransmit persistence.
  133.  * TCP_MIN_REXMT_TIME    - minimum allowable value for retransmit timer.
  134.  * TCP_MAX_REXMT_TIME    - maximum allowable value for retrans. and persist
  135.  *              timers.
  136.  *
  137.  * Other constants:
  138.  * TCP_MAX_RXT_SHIFT    - maximum number of retransmissions.
  139.  * TCP_KEEP_COUNT    - max. # of probes before we drop the connection.
  140.  */
  141.  
  142. #define    TCP_MSL_TIME        (30 * TIMER_UPDATE_RATE)
  143. #define    TCP_SRTT_BASE_TIME     (0 * TIMER_UPDATE_RATE)
  144. #define    TCP_SRTT_DEFLT_TIME     (3 * TIMER_UPDATE_RATE)
  145.  
  146. #define    TCP_KEEP_TIME_INIT    (75 * TIMER_UPDATE_RATE)
  147. #define    TCP_KEEP_TIME_IDLE    ((120*60) * TIMER_UPDATE_RATE)
  148. #define    TCP_KEEP_TIME_INTVL    (75 * TIMER_UPDATE_RATE)
  149.  
  150. #define    TCP_MIN_PERSIST_TIME     (5* TIMER_UPDATE_RATE)
  151. #define    TCP_MAX_PERSIST_TIME    (60 * TIMER_UPDATE_RATE)
  152.  
  153. #define    TCP_MIN_REXMT_TIME    ( 1 * TIMER_UPDATE_RATE)
  154. #define    TCP_MAX_REXMT_TIME    (64 * TIMER_UPDATE_RATE)
  155.  
  156. #define    TCP_KEEP_COUNT         8
  157. #define    TCP_MAX_RXT_SHIFT    12
  158.  
  159. extern int tcpKeepIdle;
  160. extern int tcpKeepIntvl;
  161. extern int tcpMaxIdle;
  162.  
  163. /*
  164.  * A macro to force a time value to be in a certain range.
  165.  */
  166. #define    TCP_TIMER_RANGESET(tv, value, tvmin, tvmax) { \
  167.     (tv) = (value); \
  168.     if ((tv) < (tvmin)) { \
  169.         (tv) = (tvmin); \
  170.     } else if ((tv) > (tvmax)) { \
  171.         (tv) = (tvmax); \
  172.     } \
  173. }
  174. #endif /* _IPS_TCP_TIMER */
  175. @
  176.  
  177.  
  178. 1.4
  179. log
  180. @Bug fixes and a patch for SPUR.
  181. @
  182. text
  183. @d18 1
  184. a18 1
  185.  * $Header: tcpTimer.h,v 1.3 88/08/16 11:22:20 mendel Exp $ SPRITE (Berkeley)
  186. d54 1
  187. a54 1
  188.  *      <SEQ=SEND.UNACK-1><ACK=RECV.NEXT><CTL=ACK> 
  189. d90 1
  190. a90 1
  191.  * TCP_MAX_REXMT_TIME    - maximum allowable value for retrans. and persist 
  192. d130 1
  193. a130 1
  194. #endif _IPS_TCP_TIMER
  195. @
  196.  
  197.  
  198. 1.3
  199. log
  200. @Converted to new lib.a.
  201. @
  202. text
  203. @d18 1
  204. a18 1
  205.  * $Header: tcpTimer.h,v 1.2 88/04/27 09:15:38 brent Exp $ SPRITE (Berkeley)
  206. d74 6
  207. a79 1
  208.  * Time constants: (In seconds)
  209. d98 3
  210. a100 3
  211. #define    TCP_MSL_TIME        30
  212. #define    TCP_SRTT_BASE_TIME     0
  213. #define    TCP_SRTT_DEFLT_TIME     3
  214. d102 3
  215. a104 3
  216. #define    TCP_KEEP_TIME_INIT    75
  217. #define    TCP_KEEP_TIME_IDLE    (120*60)
  218. #define    TCP_KEEP_TIME_INTVL    75
  219. d106 2
  220. a107 2
  221. #define    TCP_MIN_PERSIST_TIME     5
  222. #define    TCP_MAX_PERSIST_TIME    60
  223. d109 2
  224. a110 2
  225. #define    TCP_MIN_REXMT_TIME     1
  226. #define    TCP_MAX_REXMT_TIME    64
  227. @
  228.  
  229.  
  230. 1.2
  231. log
  232. @New version with Jacobson enhancements
  233. @
  234. text
  235. @d18 1
  236. a18 1
  237.  * $Header: tcpTimer.h,v 6.1 88/04/24 23:15:14 andrew Exp $ SPRITE (Berkeley)
  238. @
  239.  
  240.  
  241. 1.1
  242. log
  243. @Initial revision
  244. @
  245. text
  246. @d6 1
  247. a6 1
  248.  *    Based on 4.3BSD @@(#)tcp_timer.h    7.2 (Berkeley) 6/4/87
  249. d18 1
  250. a18 1
  251.  * $Header: tcpTimer.h,v 6.0 87/09/08 15:58:17 andrew Stable $ SPRITE (Berkeley)
  252. d47 12
  253. a58 10
  254.  * The TCP_TIMER_KEEP_ALIVE timer is used to keep connections alive.  If
  255.  * an connection is idle (no segments received) for TCP_KEEP_TIME
  256.  * amount of time, but not yet established, then we drop the connection.
  257.  * If the connection is established, then we force the peer to send us a
  258.  * segment by sending:
  259.  *    <SEQ=SEND.UNACK-1><ACK=RECV.NEXT><CTL=ACK>
  260.  * This segment is (deliberately) outside the window, and should elicit
  261.  * an ACK segment response from the peer.  If, despite the 
  262.  * TCP_TIMER_KEEP_ALIVE initiated segments we cannot elicit a response from
  263.  * a peer in TCP_MAX_IDLE_TIME amount of time, then we drop the connection.
  264. d74 1
  265. a74 1
  266.  * Time constants:
  267. d79 3
  268. a81 1
  269.  * TCP_KEEP_TIME    - keep alive.
  270. d83 1
  271. a83 2
  272.  * TCP_MAX_IDLE_TIME    - maximum allowable idle time before we drop the
  273.  *              connection.
  274. d88 1
  275. d90 1
  276. d93 1
  277. a93 1
  278. #define    TCP_MSL_TIME        15
  279. d97 4
  280. a100 2
  281. #define    TCP_KEEP_TIME        45
  282. #define    TCP_MAX_IDLE_TIME    (8 * TCP_KEEP_TIME)
  283. d102 1
  284. d105 1
  285. a105 1
  286. #define    TCP_MAX_REXMT_TIME    30
  287. d107 2
  288. a108 1
  289. #define    TCP_MAX_RXT_SHIFT     12
  290. d110 3
  291. a114 27
  292.  * Retransmission smoothing constants. Smoothed round trip time is updated by
  293.  *
  294.  *    tcpPtr->smoothRTT = (tcp_SmoothAlpha * tcpPtr->smoothRTT) + 
  295.  *                  ((1 - tcp_SmoothAlpha) * tcpPtr->roundTripTime);
  296.  *
  297.  * each time a new value of tp->roundTripTime is available.  The initial
  298.  * retransmit timeout is then based on
  299.  *
  300.  *    tcpPtr->timer[TCP_TIMER_REXMT] = tcp_SmoothBeta * tcpPtr->smoothRTT;
  301.  *
  302.  * limited, however to be at least TCP_MIN_REXMT_TIME and at most 
  303.  * TCP_MAX_REXMT_TIME.
  304.  */
  305.  
  306. extern float    tcpSmoothAlpha;
  307. extern float    tcpSmoothBeta;
  308.  
  309. /*
  310.  * Initial values of tcp_SmoothAlpha and tcp_SmoothBeta:
  311.  *   These are conservative: averaging over a long period of time, and 
  312.  *   allowing for large individual deviations from tcpPtr->smoothRTT.
  313.  */
  314.  
  315. #define    TCP_SMOOTH_ALPHA    0.9
  316. #define    TCP_SMOOTH_BETA        2.0
  317.  
  318. /*
  319. d121 1
  320. a121 2
  321.     } \
  322.     if ((tv) > (tvmax)) { \
  323. @
  324.